/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sg.edu.nus.iss.pacman.util;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;

/**
 *
 * @author Tabiul Mahmood
 */
public class PacManUtil {

    public static String getFileFromResourceStream(String path) {
        InputStream input = PacManUtil.class.getResourceAsStream(path);
        StringBuilder file = new StringBuilder();
        DataInputStream in = new DataInputStream(input);
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String strLine;
        try {
            while ((strLine = br.readLine()) != null) {
                file.append(strLine);
            }
            return file.toString();
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }

        return null;
    }

    public static String[] convertToArray(List<String> stringList){
       String[] array=new String[stringList.size()];
       int count=0;
       for(String stringValue:stringList){
           array[count]=stringValue;
           count++;
       }

       return array;
    }

}
